<template>
  <div class="warp" flex="dir:top box:first">
    <div>
      <div class="title">{{info.title}}</div>
      <ul class="list-thead">
        <li :class="`w-${item.width}`"
            v-for="(item, index) in info.titleList"
            v-bind:key="`listViewItem${index}`">
          {{item.title}}
        </li>
      </ul>
    </div>
    <div class="main-wrap">
      <div class="main-scroll">
        <ul class="list" v-if="info.dataList.length">
          <li v-for="(item, i) in info.dataList"
              v-bind:key="`item${i}`"
              flex="dir:left">
            <div v-for="(title, ii) in info.titleList"
                 :class="`text-overflow w-${title.width} ${title.colorSet ? item.color : ''}`"
                 v-bind:key="`title${ii}`">
              {{item[title.key]}}
            </div>
          </li>
        </ul>
        <div class="list-no" v-else>暂无记录</div>
      </div>
    </div>

  </div>
</template>
<script>
export default {
  name: 'listView',
  props: ['info']
}
</script>
<style lang="less" scoped>
  .c-blue {
    color: #50E3C2;
  }

  .c-red {
    color: #ff0000;
  }
  .text-overflow {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .warp {
    .title {
      color: #fff;
      font-size: 14px;
    }
    padding: 20px 15px;
    height: 100%;
    box-sizing: border-box;
  }
  .main-wrap{
    margin-top: 10px;
    position: relative;
    overflow: hidden;
    .main-scroll{
      position: absolute;
      overflow-y: scroll;
      overflow-x: hidden;
      left: 0;
      width: 100%;
      height: 100%;
    }
  }

  .list-thead {
    margin-top: 15px;
    overflow-x: hidden;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    width: 100%;
    height: 24px;
    line-height: 24px;
    font-size: 12px;
    color: #50E3C2;
    letter-spacing: 0.29px;
    text-align: center;
    li {
      display: inline-block;
    }
  }

  .list {
    /*margin-top: 10px;*/
    /*overflow-x: hidden;*/
    /*overflow-y: scroll;*/
    width: 100%;
    text-align: center;
    color: #9FACC3;
    li {
      width: 100%;
      height: 30px;
      line-height: 30px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
  }

  .main-scroll::-webkit-scrollbar {
    width: 0 !important
  }

  //chrome 和Safari
  .main-scroll {
    -ms-overflow-style: none;
  }

  //IE 10+
  .main-scroll {
    overflow: -moz-scrollbars-none;
  }

  .list-no {
    margin-top: 10px;
    text-align: center;
    color: #9FACC3;
  }
</style>
